from cart.models import Cart


def cart_processor(request):
    if request.user.is_authenticated:
        total, quantity = Cart.objects.user_sub_total(request.user)
        context = {
            'cart_processor_list': Cart.objects.filter(user=request.user).order_by("-updated")[:3],
            'cart_total': total,
            'cart_quantity': quantity
        }
    else:
        context = {'cart_processor_list': None}
    return context